package com.yxkj.railservicer.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yxkj.railservicer.R;
import com.yxkj.railservicer.bean.CompleteBean;

import java.util.List;

/**
 * Created by sunyu on 2017/4/4.
 */

public class CompleteAdapter extends RecyclerView.Adapter<CompleteAdapter.MyViewHolder> {
    private List<CompleteBean> list;
    private Context context;

    class MyViewHolder extends RecyclerView.ViewHolder {

        TextView tv_complete_firstTime;
        TextView tv_complete_order;
        TextView tv_complete_time;
        TextView tv_complete_address;

        public MyViewHolder(View itemView) {
            super(itemView);
            tv_complete_firstTime = (TextView) itemView.findViewById(R.id.tv_complete_firstTime);
            tv_complete_order = (TextView) itemView.findViewById(R.id.tv_complete_order);
            tv_complete_time = (TextView) itemView.findViewById(R.id.tv_complete_time);
            tv_complete_address = (TextView) itemView.findViewById(R.id.tv_complete_address);
        }
    }

    public CompleteAdapter(List<CompleteBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_complete, parent, false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        CompleteBean bean = list.get(position);
        holder.tv_complete_firstTime.setText(bean.getTime());
        holder.tv_complete_order.setText(bean.getOrder_num());
        holder.tv_complete_time.setText(bean.getLaterTime());
        holder.tv_complete_address.setText(bean.getAddress());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
